package com.yoshino.usercenter.once;

import com.yoshino.usercenter.mapper.UserMapper;
import com.yoshino.yoshinoapicommon.model.entity.User;
import org.springframework.stereotype.Component;
import org.springframework.util.StopWatch;

import javax.annotation.Resource;

@Component
public class InsertUsers {

    @Resource
    private UserMapper userMapper;

    /**
     * 插入用户
     */
//    @Scheduled(fixedRate = Long.MAX_VALUE)
    public  void doInsertUsers(){
        StopWatch stopWatch = new StopWatch();
        stopWatch.start();
        final int INSERT_NUM = 10000000;
        for (int i = 0; i < INSERT_NUM; i++){
            User user = new User();
            user.setUsername("假用户");
            user.setUserAccount("fakeyoshino");
            user.setAvatarUrl("http://img.faloo.com/NovelNode/0x0/1/1733/1733767.gif");
            user.setGender(0);
            user.setUserPassword("123");
            user.setPhone("111");
            user.setEmail("123@qq.com");
            user.setUserStatus(0);
            user.setUserRole("user");
            user.setPlanetCode("1123");
            user.setTags("[]");
            userMapper.insert(user);

        }
        stopWatch.stop();
        System.out.println(stopWatch.getLastTaskTimeMillis());
    }


}
